package win32api_interface.process.helper is

  --  This package contains simple calling routines to perform certain
  --  management operations with processes.

  type Process_ID_Array is array (Positive range <>) of Process_ID;
  subtype Module_Entry is MODULEENTRY32;
  type Module_Entry_Array is array (Positive range <>) of Module_Entry;
  type Module_Info is record
    Base_Address : Address;
    Base_Size    : Integer;
  end record;

  procedure Kill (PName : in String);
  --  Kills 1 process with the given image name.
  --  Full name: Kill_Process_by_Name

  function Kill_All (PName : in String) return Integer;
  --  Kills all the processes with the given image name. Returns the
  --  number of processes successfully killed.
  --  Full name: Kill_All_Process_by_Name

  function Launch (Path : in String) return Process_ID;
  --  Launches a program from a given path.  Returns its Process ID.
  --  Full name: Launch_Process_by_Path

  procedure Find (PName : in String; Result : out Process_ID; Valid : out Boolean);
  --  Finds 1 process with the given image name. Returns its ID and
  --  a boolean that specifies if the requested process image name
  --  has been found, so it also says that the returned Process_ID
  --  value is valid or not.

  function Find (PName : in String) return Process_ID;
  --  Finds 1 process with the given image name. Returns its ID.

  function Find_from_Window (WName : in String) return Process_ID;
  --  Finds 1 process with the given Window name. Returns its ID.

  function Open (ID : in Process_ID) return Handle;
  --  Gets access to the process from the given ID.
  --  Returns the access handle.
  --  Full name: Open_Process_Access

  function Launch_Open (Path : in String) return Handle;
  --  Launches a program from a given path and gets access to it.
  --  Returns the access handle.

  function Find_Open (PName : in String) return Handle;
  --  Finds 1 process with the given image name, gets access to it
  --  and returns the access handle.

  function Find_from_Window_Open (WName : in String) return Handle;
  --  Finds 1 process with the given Window name. Returns its ID.

  procedure Close (H : in Handle);
  --  Closes an access handle.

  function Find_All_Module_Entries (PID : Process_ID) return Module_Entry_Array;
  --  Returns all modules info of a given process ID.

  function Find_Module (query : string; on : Module_Entry_Array)
                        return MODULEENTRY32;
  -- Returns the given name module information. Case sensitive.

  function Get_Module_Base_Address (Module : string; Proc : Process_ID)
                                    return Address;
  -- Returns the base address of the requested module on the given process.

  function Get_Module_Info (Module : string; Proc : Process_ID)
                            return Module_Info;

  function Get_Process_Name (PID : Process_ID) return String;
  --  Returns the name of the process.  Returns an empty string if
  --  the name cannot be determined.
private
  function Get_Module_Base_Name(
             Process : Handle;
             Module  : HModule) return String;
  --  Returns the base name component of the module for the given
  --  process.

  function Get_Object_Name (Object : Handle) return Wide_String;
  --  Returns the name of an object from its Handle.

  function Find_All_Process_IDs return Process_ID_Array;
  --  Returns all the running processes IDs.

  function Find_All (Name : in String) return Process_ID_Array;
  --  Returns all the process IDs that have the given image name.
  --  Full Name: Find_All_Process_IDs_by_Name

end win32api_interface.process.helper;
